using System;
using System.IO;
using System.Text;
using SpecMaker.Core.Interfaces;

namespace SpecMaker.UnitTests.SupportClasses
{
    public class StubFileWrapper : IIOWriter
    {
        private StringBuilder _strbuilder = new StringBuilder( );

        public string StringCalled
        {
            get { return _strbuilder.ToString(); }
        }
        public void WriteLine(string s)
        {
            _strbuilder.AppendLine(s);
        }

        public void Open(string filename)
        {
            OpenCalled = true;
        }
        public bool OpenCalled
        {
            get; private set;
        }
        public bool CloseCalled
        {
            get; private set;
        }
        public void Close()
        {
            if(!OpenCalled)
            {
                 
                throw new InvalidOperationException("File cannot be closed when it is not yet open");
            }
            CloseCalled = true;
        }
    }
}